<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let random = Math.floor(Math.random() * 11)

        while (true) {
            let num = +prompt('请输入一个词')
            if (num > random) {
                alert('猜大了')
            } else if (num < random) {
                alert('猜小了')
            } else {
                alert('猜对了')
                break//一定要退出循环
            }
        }

    </script>
</body>

</html>